# -*- coding:utf8 -*-
__author__ = 'nickleo'


class TreeNodeGroup(object):
    def __init__(self, _groupName,_color, _desc):
        self._children = []
        self._tree_group_name = _groupName
        self._desc = _desc;
        self._color =_color

    @property
    def color(self):
        return self._color

    @color.setter
    def color(self, _color):
        self._color = _color

    @property
    def tree_group_name(self):
        return self._tree_group_name

    @tree_group_name.setter
    def tree_group_name(self, _tree_group_name):
        self._tree_group_name = _tree_group_name

    @property
    def desc(self):
        return self._desc

    @desc.setter
    def desc(self, _desc):
        self._desc = _desc

    @property
    def children(self):
        return self._children

    @children.setter
    def children(self, _children):
        self._children = _children

    def add_child(self, *child):
        self._children += child


class TreeNode(object):
    def __init__(self, _node_id, _color, _desc):
        self._children = []
        self._node_id = _node_id
        self._color = _color
        self._desc = _desc

    @property
    def desc(self):
        return self._desc

    @desc.setter
    def desc(self, _desc):
        self._desc = _desc

    @property
    def node_id(self):
        return self._node_id

    @node_id.setter
    def node_id(self, _node_id):
        self._node_id = _node_id

    @property
    def color(self):
        return self._color

    @color.setter
    def color(self, _color):
        self._color = _color

    def show(self, layer):
        print "   " * layer + self.node_id
        map(lambda child: child.show(layer + 1), self._children)

    @property
    def children(self):
        return self._children

    @children.setter
    def children(self, _children):
        self._children = _children

    def add_child(self, *child):
        self._children += child


def main():
    a1 = TreeNode("topic_test1", 'warning', '')
    b1 = TreeNode("broker01", 'warning', '1111')
    b2 = TreeNode("broker02", 'warning', '222222')
    c1 = TreeNode("mq 01", 'warning', '3333333')
    c2 = TreeNode("mq 02", 'success', 'aaaaaaa')
    c3 = TreeNode("mq 03", 'error', 'vvvvvvvvvvvv')
    a1.add_child(b1, b2)
    b1.add_child(c1, c2, c3)
    b2.add_child(c1)

    print a1.node_id
    for node in a1.children:
        print node.node_id


if __name__ == "__main__": main()